package redis.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import redis.service.CacheService;

@RestController
public class CacheController {
    private final CacheService cacheService;

    @Autowired
    public CacheController(CacheService cacheService) {
        this.cacheService = cacheService;
    }

    @GetMapping("/init")
    public String initData() {
        cacheService.initData();
        return "Data initialized successfully!";
    }

    @GetMapping("/item")
    public String getItem(@RequestParam String key) {
        return cacheService.getItem(key);
    }
}